package me.send.data.service.provider;

import java.util.Map;

import me.send.business.base.Pager;

public class FeedbackProvider {

	public String list_broker(Map<String, Object> param) {
    	String sql = "select f.*,p.telephone,p.username from feedback f left join `popuser` p on f.popid=p.popid where p.popid>0 ";
    	if (param != null) {
    		String phone = (String) param.get("phone");
    		String start=(String) param.get("start");
    		String end=(String) param.get("end");
    		Pager page=(Pager) param.get("page");
    		if (phone!=null&&!phone.equals("")) {
    			sql += " and p.telephone=" + phone;
    		}
    		if(start!=null&&!start.equals("")){
    			sql+=" and f.createtime>='"+start+"'";
    		}
    		if(end!=null&&!end.equals("")){
    			sql+=" and f.createtime<'"+end+"'";
    		}
    		sql += " limit " + page.getStart() + "," + page.getRows();
    	}
    	return sql;
    }
    public String count_broker(Map<String, Object> param) {
    	String sql = "select count(1) from feedback f left join `popuser` p on f.popid=p.popid where p.popid>0 ";
    	if (param != null) {
    		String phone = (String) param.get("phone");
    		String start=(String) param.get("start");
    		String end=(String) param.get("end");
    		if (phone!=null&&!phone.equals("")) {
    			sql += " and p.telephone=" + phone;
    		}
    		if(start!=null&&!start.equals("")){
    			sql+=" and f.createtime>='"+start+"'";
    		}
    		if(end!=null&&!end.equals("")){
    			sql+=" and f.createtime<'"+end+"'";
    		}
    	}
    	return sql;
    }
    
    public String list_user(Map<String, Object> param) {
    	String sql = "select f.*,u.telephone,u.nickname from feedback f left join `user` u on f.userid=u.userid where u.userid>0 ";
    	if (param != null) {
    		String phone = (String) param.get("phone");
    		String start=(String) param.get("start");
    		String end=(String) param.get("end");
    		Pager page=(Pager) param.get("page");
    		if (phone!=null&&!phone.equals("")) {
    			sql += " and u.telephone=" + phone;
    		}
    		if(start!=null&&!start.equals("")){
    			sql+=" and f.createtime>='"+start+"'";
    		}
    		if(end!=null&&!end.equals("")){
    			sql+=" and f.createtime<'"+end+"'";
    		}
    		sql += " limit " + page.getStart() + "," + page.getRows();
    	}
    	return sql;
    }
    public String count_user(Map<String, Object> param) {
    	String sql = "select count(1) from feedback f left join `user` u on f.userid=u.userid where u.userid>0 ";
    	if (param != null) {
    		String phone = (String) param.get("phone");
    		String start=(String) param.get("start");
    		String end=(String) param.get("end");
    		if (phone!=null&&!phone.equals("")) {
    			sql += " and u.telephone=" + phone;
    		}
    		if(start!=null&&!start.equals("")){
    			sql+=" and f.createtime>='"+start+"'";
    		}
    		if(end!=null&&!end.equals("")){
    			sql+=" and f.createtime<'"+end+"'";
    		}
    	}
    	return sql;
    }
    
    
    
	
}
